<?php
class SysUserAction extends CommonAction {

    protected $_str_model           = 'SysUser';
    protected $_arr_search          = array(
                                            'user_id'            => array('LIKE', '%?%', 'int'),
                                            'user_name'          => array('LIKE', '%?%', 'str'),
                                            'is_admin'           => array('EQ', '?', 'int'),
                                            'status'             => array('EQ', '?', 'int'),
                                            'last_login_time'    => array('BETWEEN', '?1, ?2', 'str'),
                                      );
    protected $_str_status_type     = 'all';
    
    /**
     * Set params
     * global settings, for index, edit, add
     * 
     * @param  void
     * @return void
     * @author andy
     */
    public function set_params() {
        
        $this->assign('arr_group', set_array_key(D('SysGroup')->get_all(), 'group_id', 'name'));
    }
    
    /**
     * Set params edit
     * 
     * @param  void
     * @return void
     * @author andy
     */
    public function set_params_edit() {

        $arr_info = $this->get('arr_info');
        $this->assign('arr_group_ids', explode(',', $arr_info['group_ids']));
    }

    /**
     * Before do action
     * for edit, add
     * 
     * @param  void
     * @return void
     * @author andy
     */
    public function before_do_action() {

        set_post('password', md5($this->_post('password')));
        set_post('group_ids', implode(',', $this->_post('group_ids')));
    }
}